package com.solidumgame.ninja.knife
{
	import Box2D.Dynamics.b2Body;
	
	import com.greensock.TweenMax;
	import com.greensock.easing.Linear;
	import com.pblabs.box2D.CollisionEvent;
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.components.AnimatedComponent;
	import com.pblabs.engine.core.InputMap;
	import com.pblabs.engine.core.ProcessManager;
	import com.pblabs.engine.entity.PropertyReference;
	
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.media.Sound;
	import flash.media.SoundLoaderContext;
	import flash.net.URLRequest;
	import flash.ui.Mouse;
	
	/**
	 * 
	 * @author martin
	 * 
	 */
	public class KnifeLogicComponent extends AnimatedComponent
	{	
		public var point:Point;
		public var movePoint:Point;
		
		public function KnifeLogicComponent()
		{	
			super();
		}
				
		override protected function onAdd():void{
			super.onAdd();
			this.updatePriority=1000;
			//owner.eventDispatcher.addEventListener(MouseEvent.MOUSE_MOVE, move);
			//ProcessManager
		}		
				
		override protected function onReset():void{
			super.onReset();
			//owner.eventDispatcher.addEventListener(MouseEvent.MOUSE_MOVE, move);
		}
		
		private function move(e:MouseEvent):void{
			//movePoint = new Point(PBE.mainStage.mouseX-320,PBE.mainStage.mouseY-240);
			//if(owner)
				//owner.setProperty(new PropertyReference("@Spatial.position"),movePoint);
		}
		
		private function updatePoint(point:Point):void{
			this.point = point;
		}
		
		override public function onFrame(tickRate:Number):void{
			super.onFrame(tickRate);
			movePoint = new Point(PBE.mainStage.mouseX-320,PBE.mainStage.mouseY-240);
			updatePoint(movePoint);
			if(owner)
				owner.setProperty(new PropertyReference("@Spatial.position"),point);
		}
				
		override protected function onRemove():void{
			super.onRemove();
		}
	}
}